package com.woniuxy.controller;


import com.woniuxy.common.Result;
import com.woniuxy.service.FoodMonthSaleService;
import com.woniuxy.service.dto.FoodParentTypeDto;
import com.woniuxy.service.dto.FoodSaleDto;
import com.woniuxy.service.dto.StoreSaleDto;
import com.woniuxy.util.RedisUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 菜品月销量表 前端控制器
 * </p>
 *
 * @author zz
 * @since 2023年06月13日
 */
@RestController
@Api(tags = "销量模块相关接口")
@RequestMapping("/foodMonthSale")
public class FoodMonthSaleController {

    @Autowired
    private FoodMonthSaleService foodMonthSaleService;
    @Autowired
    private RedisUtil redisUtil;

    @ApiOperation("获取当前商家上个月菜品销量前5的数据")
    @GetMapping("/showFoodSale")
    public Result showFoodSale(@RequestHeader String accessToken) throws Exception{
        Long accountId = redisUtil.getUserIdByToken(accessToken).longValue();
        List<FoodSaleDto> list = foodMonthSaleService.showFoodSale(accountId);
        return Result.success(200,"获取菜品销量前5的数据成功",list);
    }

    @ApiOperation("获取当前商家近三个月的总销售情况")
    @GetMapping("/showStoreSale")
    public Result showStoreSale(@RequestHeader String accessToken) throws Exception{
        Long accountId = redisUtil.getUserIdByToken(accessToken).longValue();
        List<StoreSaleDto> list = foodMonthSaleService.showStoreSale(accountId);
        return Result.success(200,"获取当前商家近三个月的总销售情况成功",list);
    }


}

